﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SGameCommon;
using SGameBLL;

namespace SGame.Web
{
    public partial class SGameLogin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        #region 登录
        protected void LogLBtn_Click(object sender, EventArgs e)
        {
            string account = Request["name"].ToString();
            string password = Request["pass"].ToString();
            if (string.IsNullOrEmpty(account))
            {
                JSHelper.Alert(this, "您的账号不能为空！");
                return;
            }
            if (string.IsNullOrEmpty(password))
            {
                JSHelper.Alert(this, "您的密码不能为空！");         
                return;
            }
            LoginBLL loginBLL = new LoginBLL();
            object res = loginBLL.GetLongin(account, password);
            if (res != null)
            {
                JSHelper.Alert(this, "登录成功！");
            }
            else
            {
                JSHelper.Alert(this, "您的账号或密码有误！");
            }
        }
        #endregion
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void RegLBtn_Click(object sender, EventArgs e)
        {
            string account = Request["regname"].ToString();
            string password = Request["regpass"].ToString();
            string reregpass = Request["reregpass"].ToString();
            if (string.IsNullOrEmpty(account))
            {
                JSHelper.Alert(this, "您的账号不能为空！");
                return;
            }
            if (string.IsNullOrEmpty(password))
            {
                JSHelper.Alert(this, "您的密码不能为空！");
                return;
            }
            if (string.IsNullOrEmpty(reregpass))
            {
                JSHelper.Alert(this, "您的确认密码不能为空！");
                return;
            }
            if (password != reregpass)
            {
                JSHelper.Alert(this, "二次密码不一致！");
            }
            LoginBLL loginBLL = new LoginBLL();
            Object reg= loginBLL.GetReg(account, password);
            if (reg != null)
            {
                JSHelper.Alert(this, "注册成功！");
            }
            else
            {
                JSHelper.Alert(this, "注册失败！");
            }
           
        }
    }
}